﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCCommon;
using BCDto.Common.OA.WorkOvertimeExamineFlowRule;
using BCService.CommonService.OA.WorkOvertimeExamineFlowRule;
using BlackCoffeeRESTful.Configs;
using Microsoft.AspNetCore.Mvc;

namespace BlackCoffeeRESTful.Controllers.Management.OA
{
    /// <summary>
    /// 加班审批流程规则
    /// </summary>
    [ApiExplorerSettings(GroupName = "OAAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class WorkOvertimeExamineFlowRuleController : ManagementBaseController
    {
        private readonly IWorkOvertimeExamineFlowRuleService workOvertimeExamineFlowRuleService;

        public WorkOvertimeExamineFlowRuleController(IWorkOvertimeExamineFlowRuleService workOvertimeExamineFlowRuleService)
        {
            this.workOvertimeExamineFlowRuleService = workOvertimeExamineFlowRuleService;
        }

        #region 创建加班审批流程规则信息
        /// <summary>
        /// 创建一条加班审批流程规则信息
        /// </summary>
        /// <param name="requestDto">加班审批流程规则信息</param>
        /// <response code="200">新创建的加班审批流程规则信息</response>
        /// <returns></returns>
        [HttpPost]
        [Log("创建一条加班审批流程规则信息")]
        [ProducesResponseType(typeof(WorkOvertimeExamineFlowRuleDto), 200)]

        public IActionResult Post([FromBody] WorkOvertimeExamineFlowRuleRequestDto requestDto)
        {

            return Ok(this.workOvertimeExamineFlowRuleService.Create(requestDto));
        }
        #endregion

        #region 修改一条加班审批流程规则信息

        /// <summary>
        /// 修改加班审批流程规则信息
        /// </summary>
        /// <param name="workOverTimeExamineFlowRuleNo">加班审批流程规则信息ID</param>
        /// <param name="workOverTimeExamineFlowRuleSimPutDto">修改的加班审批流程规则信息模型</param>    
        /// <returns></returns>
        /// <response code="200">修改后的加班审批流程规则信息。</response>
        [HttpPut("{work_over_time_examine_flow_rule_no}")]
        [Log("修改加班审批流程规则信息")]
        [ProducesResponseType(typeof(WorkOvertimeExamineFlowRuleDto), 200)]
        public IActionResult Put([FromRoute(Name = "work_over_time_examine_flow_rule_no")] long workOverTimeExamineFlowRuleNo, [FromBody] WorkOvertimeExamineFlowRuleSimPutDto workOverTimeExamineFlowRuleSimPutDto)
        {
            return this.Ok(this.workOvertimeExamineFlowRuleService.Update(workOverTimeExamineFlowRuleNo, workOverTimeExamineFlowRuleSimPutDto));
        }

        #endregion

        #region 删除一条加班审批流程规则信息
        /// <summary>
        /// 删除一条加班审批流程规则信息
        /// </summary>
        /// <param name="workOverTimeExamineFlowRuleNo">加班审批流程规则信息ID</param>
        /// <returns></returns>
        /// <response code="204">刪除一条加班审批流程规则信息成功。</response>
        [HttpDelete("{work_over_time_examine_flow_rule_no}")]
        [Log("删除一条加班审批流程规则信息")]
        public IActionResult Delete([FromRoute(Name = "work_over_time_examine_flow_rule_no")]long workOverTimeExamineFlowRuleNo)
        {
            this.workOvertimeExamineFlowRuleService.Delete(workOverTimeExamineFlowRuleNo);
            return NoContent();
        }
        #endregion

        #region 获取一条加班审批流程规则信息
        /// <summary>
        /// 获取一条加班审批流程规则信息
        /// </summary>
        /// <param name="workOverTimeExamineFlowRuleNo">加班审批流程规则信息ID</param>
        /// <returns></returns>
        [HttpGet("{work_over_time_examine_flow_rule_no}")]
        [ProducesResponseType(typeof(WorkOvertimeExamineFlowRuleDto), 200)]

        public IActionResult Get([FromRoute(Name = "work_over_time_examine_flow_rule_no")] long workOverTimeExamineFlowRuleNo)
        {
            return Ok(this.workOvertimeExamineFlowRuleService.Get(workOverTimeExamineFlowRuleNo));
        }

        #endregion

        #region 获取加班审批流程规则信息接口（分页）
        /// <summary>
        /// 获取加班审批流程规则信息列表（分页）
        /// </summary>
        /// <param name="adminName">参与者管理员名称</param>
        /// <param name="departmentName">部门名称</param>
        /// <param name="departmentId">部门ID</param>
        /// <param name="adminId">参与者管理员ID</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="ascending">是否升序</param>     
        /// <param name="pageIndex">以 1 起始的页码 (默认 1)。</param>
        /// <param name="pageSize">每页要显示的行数 (默认 10)。</param>
        /// <response code="200">带有分页信息的加班审批流程规则列表。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<WorkOvertimeExamineFlowRuleDto>), 200)]
        public IActionResult List([FromQuery(Name = "admin_name")]string adminName,
            [FromQuery(Name = "department_name")]string departmentName,
            [FromQuery(Name = "department_id")]int? departmentId,
            [FromQuery(Name = "admin_id")] long? adminId,
            [FromQuery(Name = "start")]DateTime? start,
            [FromQuery(Name = "end")]DateTime? end,
            [FromQuery(Name = "ascending")]bool? ascending,
            int pageIndex = 1,
            int pageSize = 10)
        {
            var list = this.workOvertimeExamineFlowRuleService.List(adminName, departmentName, departmentId, adminId,  start, end, ascending, pageIndex, pageSize);
            return this.Ok(list);

        }
        #endregion
    }
}